﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;

namespace Userinterface_Ver._1_
{
    public partial class frmDoiMK : DevComponents.DotNetBar.Office2007Form
    {
        string tendn = "";
        string mk = "";
        public frmDoiMK()
        {
            InitializeComponent();
        }

        private void frmDoiMK_Load(object sender, EventArgs e)
        {
            try
            {
                string sql = "select USER_NAME, PASS_WORD FROM USERS WHERE USER_NAME = '" + frmLogin.tenDN + "'";
                OracleCommand com = new OracleCommand(sql, clsConnectDatabase.con);
                OracleDataReader dr = com.ExecuteReader();
                dr.Read();
                tendn = dr.GetString(0);
                mk = dr.GetString(1);
            }
            catch (OracleException ex)
            {
                MessageBox.Show(ex.Message,"loi he thong");
            }
        }

        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (txtMKC.Text == mk)
            {
                string sql = "UPDATE USERS SET PASS_WORD = '" + txtXNMK.Text + "' WHERE USER_NAME = '" + tendn + "'";
                OracleCommand com = new OracleCommand(sql, clsConnectDatabase.con);
                com.ExecuteNonQuery();
            }
            else
            {
                MessageBox.Show("mật khẩu không khớp!!");
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
